/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package desenho;

import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import javax.media.j3d.*;
import javax.media.j3d.Node;
import javax.vecmath.*;

/**
 *
 * @author fosa
 */
public class db3d00 {

    public db3d00() {
        SimpleUniverse universe = new SimpleUniverse();

        BranchGroup Grupo = new BranchGroup();
//        Grupo.addChild(new ColorCube(0.4));

//        Background back = new Background(new Color3f(1.1f, 1.1f, 1.1f));

//        Grupo.addChild(back);

        Sphere sphere = new Sphere(0.1f);

        Text3D text = new Text3D(new Font3D(new Font("georgia", 0, 12), new FontExtrusion(new Shape() {

            public Rectangle getBounds() {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public Rectangle2D getBounds2D() {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public boolean contains(double x, double y) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public boolean contains(Point2D p) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public boolean intersects(double x, double y, double w, double h) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public boolean intersects(Rectangle2D r) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public boolean contains(double x, double y, double w, double h) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public boolean contains(Rectangle2D r) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public PathIterator getPathIterator(AffineTransform at) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public PathIterator getPathIterator(AffineTransform at, double flatness) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        })));

        TransformGroup tg = new TransformGroup();

        Transform3D transform = new Transform3D();

        Vector3f vector = new Vector3f(.2f, .2f, .2f);
//        Vector3f vector1 = new Vector3f(.5f, .5f, .0f);

        transform.setTranslation(vector);

        tg.setTransform(transform);

        tg.addChild(sphere);

        Grupo.addChild(tg);

        Color3f light1Color = new Color3f(5.1f, 5.1f, 5.1f);

        BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

        Vector3f light1Direction = new Vector3f(10.0f, -10.0f, -10.0f);

        DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);

        light1.setInfluencingBounds(bounds);

        Grupo.addChild(light1);



//        universe.addBranchGraph(Grupo);

        text.setString("Fosa");




        Plano(Grupo);

//        System.out.println(universe.getViewer());
        universe.getViewingPlatform().setNominalViewingTransform();
        universe.addBranchGraph(Grupo);


//     group.addChild(new com.sun.j3d.utils.geometry.Box(1));

//     group.addChild(new ColorCube(0.1));
    }

    public void Plano(BranchGroup _Grupo) {
        for (float x = -1.0f; x <= 1.0f; x = x + 0.1f) {

            Sphere sphere2 = new Sphere(0.01f);

            TransformGroup tg = new TransformGroup();

            Transform3D transform = new Transform3D();

            Vector3f vector = new Vector3f(x, .0f, .0f);

            transform.setTranslation(vector);

            tg.setTransform(transform);

            tg.addChild(sphere2);

            _Grupo.addChild(tg);

        }

        for (float y = -1.0f; y <= 1.0f; y = y + 0.1f) {

            Sphere sphere2 = new Sphere(0.01f);

            TransformGroup tg = new TransformGroup();

            Transform3D transform = new Transform3D();

            Vector3f vector = new Vector3f(.0f, y, .0f);

            transform.setTranslation(vector);

            tg.setTransform(transform);

            tg.addChild(sphere2);

            _Grupo.addChild(tg);

        }

        for (float z = -1.0f; z <= 1.0f; z = z + 0.1f) {

            Sphere sphere2 = new Sphere(0.01f);

            TransformGroup tg = new TransformGroup();

            Transform3D transform = new Transform3D();

            Vector3f vector = new Vector3f(.0f, .0f, z);

            transform.setTranslation(vector);

            tg.setTransform(transform);

            tg.addChild(sphere2);

            _Grupo.addChild(tg);

        }
    }

    public static void main(String[] args) {
        new db3d00();
    }
}

